/*************************************************************************
    > File Name: 2.ntohl.c
    > Author: Ykk
    > Mail: 3393579535@qq.com 
    > Created Time: 2023年05月15日 星期一 19时33分48秒
 ************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>

int main(int argc, char *argv[])
{
    unsigned char buf[4] = {192, 168, 1, 2};
    uint32_t num = 0;

    memcpy(&num, buf, sizeof(num));
    num = ntohl(num);

    printf("%u.%u.%u.%u\n", (num >> 24) & 0xFF, (num >> 16) & 0xFF, (num >> 8) & 0xFF, num & 0xFF);
	
	unsigned int a = 0x12345678;
	unsigned int b = ntohl(a);
	printf("%x\n",b);
    return 0;
}
